<template>
    <el-form style="width: 60%"  ref="updateFormRef" :model="updateForm" label-width="100px" class="demo-ruleForm">

        <!-- 姓名-->
        <el-form-item prop="name" label="姓名:">
            <el-input v-model="updateForm.name" :disabled="true"></el-input>
        </el-form-item>
        <el-form-item label="起始日期">
            <el-col :span="11">
                <el-date-picker type="date" placeholder="选择日期" v-model="updateForm.beginDate" style="width: 100%;"></el-date-picker>
            </el-col>
        </el-form-item>
        <el-form-item label="结束日期">
            <el-col :span="11">
                <el-date-picker type="date" placeholder="选择日期" v-model="updateForm.endDate" style="width: 100%;"></el-date-picker>
            </el-col>
        </el-form-item>
        <el-form-item label="请假原因:">
            <el-input type="textarea" v-model="updateForm.reason"></el-input>
        </el-form-item>
        <div class="button" style=
                "display: flex;
         justify-content: flex-end;">
            <el-button  @click="application()" type="success">提交</el-button>
            <el-button  @click="reset()" type="info">重置</el-button>
        </div>
    </el-form>
</template>

<script>
    export default {
        data() {
            return {
                //表单数据
                updateForm:{
                    name: window.sessionStorage.getItem("name")
                },
            };
        },
        methods: {
            application(){
                var date1=(String)(this.updateForm.beginDate.getFullYear())+"-"+
                    (String)(this.updateForm.beginDate.getMonth()+1)+"-"+
                    (String)(this.updateForm.beginDate.getDate());
                var date2=(String)(this.updateForm.endDate.getFullYear())+"-"+
                    (String)(this.updateForm.endDate.getMonth()+1)+"-"+
                    (String)(this.updateForm.endDate.getDate());

                this.updateForm.beginDate=date1;
                this.updateForm.endDate=date2;
                this.updateForm.status="待审核";
                console.log(this.updateForm.beginDate);
                console.log(this.updateForm.endDate);
                console.log(this.updateForm);
                 this.$http.post("holiday/save",this.updateForm).then(function(resp){

                 })

                this.$message.success("提交成功");

                clearTimeout(this.timer);  //清除延迟执行

                this.timer = setTimeout(()=>{   //设置延迟执行
                    this.$router.push({path: "/home/States"});
                },100);

            },
            reset(){
                location.reload();
            },
        },
        created() {

        }
    }
</script>
